// 1. 引入异步对象
import request from '@/utils/request'
import { reqGetSpuSaleAttrList } from './spu'

// 枚举储存接口
enum Api {
  // 根据spuId 获取sku数据 get /admin/product/findBySpuId/{spuId} 
  getSkuList = '/admin/product/findBySpuId',

   // 添加SkuInfo post /admin/product/saveSkuInfo 
   saveSpuInfo = '/admin/product/saveSkuInfo',

  //  查看所有skuInfo列表 get /admin/product/list/{page}/{limit} 
  getAllSku = '/admin/product/list',

  // 上架商品 get /admin/product/onSale/{skuId} 
  onSaleSku = '/admin/product/onSale',

    // 上架商品 get /admin/product/cancelSale/{skuId} 
  cancelSaleSku = '/admin/product/cancelSale',

  // 删除商品 delete /admin/product/deleteSku/{skuId} 
  deleteSku = '/admin/product/deleteSku',

  // 根据id获取一条skuInfo的详细数据 这个接口变了
  getSkuInfoApi = '/admin/product/getSkuById'
}
//1.获取sku数据 
export const reqGetSkuList = (spuId:number) => {
  return request.get(Api.getSkuList + `/${spuId} `)
}

//2.添加SkuInfo
export const reqPostSaveSpuInfo = (skuInfo:any) => {
  return request.post(Api.saveSpuInfo,skuInfo)
}

//3.查看所有skuInfo列表
export const reqGetAllSkuList = (page:number,limit:number) => {
  return request.get(Api.getAllSku+`/${page}/${limit}`)
}

//4.上架商品
export const reqGetOnSaleSkuInfo = (skuId:number) => {
  return request.get(Api.onSaleSku + `/${skuId}`)
}

//5.上下架商品
export const reqGetCancelSaleSkuInfo = (skuId:number) => {
  return request.get(Api.cancelSaleSku + `/${skuId}`)
}

//6.删除商品
export const reqDelSkuInfo = (skuId:number) => {
  return request.delete(Api.deleteSku + `/${skuId}`)
}

//7.根据id获取一条skuInfo的详细数据
export const reqGetOneSkuInfo = (skuId:number) => {
  return request.get(Api.getSkuInfoApi + `/${skuId}`)
}